/* Class35 - Decompiled by JODE
 * Visit http://jode.sourceforge.net/
 */
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.io.IOException;

public class Class35 implements KeyListener, FocusListener {
	public static JString aClass3_616;
	public static JString aClass3_617 = Class39_Sub5_Sub9.createJString(108, "Please subscribe)1 or use a different world)3");
	public static int absoluteRegionY;
	public static JString aClass3_619;
	public static JString aClass3_620;
	public static int[] anIntArray621;
	public static JString aClass3_622;
	public static JString aClass3_623;
	public static JString aClass3_624;
	public static JString aClass3_625;
	public static long serverSessionKey;
	public static JString aClass3_627;
	public static boolean aBoolean628;
	public static Class39_Sub5_Sub10_Sub4 aClass39_Sub5_Sub10_Sub4_629;

	public synchronized void keyPressed(KeyEvent keyevent) {
		if (Class39_Sub5_Sub4_Sub4_Sub1.aClass35_2499 != null) {
			Class39_Sub5_Sub7.anInt1779 = 0;
			int i = keyevent.getKeyCode();
			if (i < 0 || i >= Player.anIntArray2532.length)
				i = -1;
			else {
				i = Player.anIntArray2532[i];
				if ((i & 0x80) != 0)
					i = -1;
			}
			int i_0_;
			if (i != 85 && i != 80 && i != 84 && i != 0 && i != 101)
				i_0_ = Class39_Sub5_Sub16.method744(keyevent, 8);
			else
				i_0_ = -1;
			if (Class18.anInt341 >= 0 && i >= 0) {
				Class39_Sub5_Sub11.anIntArray1847[Class18.anInt341] = i;
				Class18.anInt341 = Class18.anInt341 + 1 & 0x7f;
				if (Class18.anInt341 == Class46.anInt879)
					Class18.anInt341 = -1;
			}
			if (i >= 0 || i_0_ >= 0) {
				int i_1_ = GameCharacter.anInt2299 + 1 & 0x7f;
				if (i_1_ != Stream.anInt1368) {
					Class46.anIntArray883[GameCharacter.anInt2299] = i;
					Class46_Sub1.anIntArray1558[(GameCharacter.anInt2299)] = i_0_;
					GameCharacter.anInt2299 = i_1_;
				}
			}
		}
		keyevent.consume();
	}

	public static boolean method343(int i) {
		long l = Class2.method51(i ^ 0x255);
		int i_2_ = (int) (-PacketParser.aLong1063 + l);
		PacketParser.aLong1063 = l;
		if (i_2_ > 200)
			i_2_ = 200;
		Class40.anInt748 += i_2_;
		if (Canvas_Sub1.anInt21 == 0 && Class1.anInt31 == 0 && Class41.anInt766 == 0 && Class39_Sub5_Sub6.anInt1765 == 0)
			return true;
		if (Deque.aClass16_923 == null)
			return false;
		try {
			if (Class40.anInt748 > 30000)
				throw new IOException();
			for (/**/; Class1.anInt31 < 20; Class1.anInt31++) {
				if (Class39_Sub5_Sub6.anInt1765 <= 0)
					break;
				Class39_Sub5_Sub3 class39_sub5_sub3 = (Class39_Sub5_Sub3) Login.aClass19_461.method239(70);
				Stream class39_sub6 = new Stream(4);
				class39_sub6.writeByte((byte) -28, 1);
				class39_sub6.write3Bytes((int) class39_sub5_sub3.hash);
				Deque.aClass16_923.write(-1, class39_sub6.buffer, 4, 0);
				CacheIO.aClass19_95.method238(class39_sub5_sub3.hash, class39_sub5_sub3, (byte) -15);
				Class39_Sub5_Sub6.anInt1765--;
			}
			for (/**/; Canvas_Sub1.anInt21 < 20 && Class41.anInt766 > 0; Canvas_Sub1.anInt21++) {
				Class39_Sub5_Sub3 class39_sub5_sub3 = ((Class39_Sub5_Sub3) Class32.aClass54_583.method988((byte) -123));
				Stream class39_sub6 = new Stream(4);
				class39_sub6.writeByte((byte) -28, 0);
				class39_sub6.write3Bytes((int) class39_sub5_sub3.hash);
				Deque.aClass16_923.write(-1, class39_sub6.buffer, 4, 0);
				class39_sub5_sub3.method461(16777215);
				Class19.aClass19_370.method238(class39_sub5_sub3.hash, class39_sub5_sub3, (byte) -49);
				Class41.anInt766--;
			}
			int i_3_ = 0;
			if (i != 512)
				method346((byte) 78, -62, null);
			for (/**/; i_3_ < 100; i_3_++) {
				int i_4_ = Deque.aClass16_923.available();
				if (i_4_ < 0)
					throw new IOException();
				if (i_4_ == 0)
					break;
				Class40.anInt748 = 0;
				int i_5_ = 0;
				if (CacheArchive.aClass39_Sub5_Sub3_1285 != null) {
					if (Class39_Sub4.anInt1331 == 0)
						i_5_ = 1;
				} else
					i_5_ = 8;
				if (i_5_ > 0) {
					int i_6_ = -Applet_Sub1.aClass39_Sub6_3.currentOffset + i_5_;
					if (i_6_ > i_4_)
						i_6_ = i_4_;
					Deque.aClass16_923.read(i_6_, Applet_Sub1.aClass39_Sub6_3.buffer, Applet_Sub1.aClass39_Sub6_3.currentOffset);
					if (Applet_Sub1.aByte1 != 0) {
						for (int i_7_ = 0; i_7_ < i_6_; i_7_++)
							Applet_Sub1.aClass39_Sub6_3.buffer[Applet_Sub1.aClass39_Sub6_3.currentOffset + i_7_] = (byte) (Class39_Sub5_Sub4_Sub4_Sub1.method522((Applet_Sub1.aClass39_Sub6_3.buffer[(Applet_Sub1.aClass39_Sub6_3.currentOffset) + i_7_]), Applet_Sub1.aByte1));
					}
					Applet_Sub1.aClass39_Sub6_3.currentOffset += i_6_;
					if (i_5_ > Applet_Sub1.aClass39_Sub6_3.currentOffset)
						break;
					if (CacheArchive.aClass39_Sub5_Sub3_1285 == null) {
						Applet_Sub1.aClass39_Sub6_3.currentOffset = 0;
						int i_8_ = Applet_Sub1.aClass39_Sub6_3.readByte((byte) -8);
						int i_9_ = Applet_Sub1.aClass39_Sub6_3.readShort(102);
						int i_10_ = Applet_Sub1.aClass39_Sub6_3.readByte((byte) -8);
						long l_11_ = (long) (i_9_ + (i_8_ << 16));
						int i_12_ = Applet_Sub1.aClass39_Sub6_3.readInt();
						Class39_Sub5_Sub3 class39_sub5_sub3 = ((Class39_Sub5_Sub3) CacheIO.aClass19_95.method245((byte) -19, l_11_));
						Class41.aBoolean777 = true;
						if (class39_sub5_sub3 == null) {
							class39_sub5_sub3 = ((Class39_Sub5_Sub3) Class19.aClass19_370.method245((byte) -19, l_11_));
							Class41.aBoolean777 = false;
						}
						if (class39_sub5_sub3 == null)
							throw new IOException();
						CacheArchive.aClass39_Sub5_Sub3_1285 = class39_sub5_sub3;
						int i_13_ = i_10_ != 0 ? 9 : 5;
						Class42.aClass39_Sub6_788 = new Stream(i_13_ + (i_12_ + (CacheArchive.aClass39_Sub5_Sub3_1285.aByte1715)));
						Class42.aClass39_Sub6_788.writeByte((byte) -28, i_10_);
						Class42.aClass39_Sub6_788.writeInt(i_12_);
						Class39_Sub4.anInt1331 = 8;
						Applet_Sub1.aClass39_Sub6_3.currentOffset = 0;
					} else if (Class39_Sub4.anInt1331 == 0) {
						if (Applet_Sub1.aClass39_Sub6_3.buffer[0] == -1) {
							Applet_Sub1.aClass39_Sub6_3.currentOffset = 0;
							Class39_Sub4.anInt1331 = 1;
						} else
							CacheArchive.aClass39_Sub5_Sub3_1285 = null;
					}
				} else {
					int i_14_ = (-CacheArchive.aClass39_Sub5_Sub3_1285.aByte1715 + Class42.aClass39_Sub6_788.buffer.length);
					int i_15_ = -Class39_Sub4.anInt1331 + 512;
					if (i_14_ - Class42.aClass39_Sub6_788.currentOffset < i_15_)
						i_15_ = i_14_ - Class42.aClass39_Sub6_788.currentOffset;
					if (i_4_ < i_15_)
						i_15_ = i_4_;
					Deque.aClass16_923.read(i_15_, Class42.aClass39_Sub6_788.buffer, Class42.aClass39_Sub6_788.currentOffset);
					if (Applet_Sub1.aByte1 != 0) {
						for (int i_16_ = 0; i_15_ > i_16_; i_16_++)
							Class42.aClass39_Sub6_788.buffer[Class42.aClass39_Sub6_788.currentOffset + i_16_] = (byte) (Class39_Sub5_Sub4_Sub4_Sub1.method522((Class42.aClass39_Sub6_788.buffer[(Class42.aClass39_Sub6_788.currentOffset) + i_16_]), Applet_Sub1.aByte1));
					}
					Class42.aClass39_Sub6_788.currentOffset += i_15_;
					Class39_Sub4.anInt1331 += i_15_;
					if (i_14_ == Class42.aClass39_Sub6_788.currentOffset) {
						if (CacheArchive.aClass39_Sub5_Sub3_1285.hash == 16711935L) {
							Class57_Sub2.aClass39_Sub6_1581 = Class42.aClass39_Sub6_788;
							for (int i_17_ = 0; i_17_ < 256; i_17_++) {
								CacheArchive class9_sub1 = Class33.aClass9_Sub1Array600[i_17_];
								if (class9_sub1 != null) {
									Class57_Sub2.aClass39_Sub6_1581.currentOffset = i_17_ * 4 + 5;
									int i_18_ = Class57_Sub2.aClass39_Sub6_1581.readInt();
									class9_sub1.method170(116, i_18_);
								}
							}
						} else {
							Class39_Sub5_Sub16.aCRC32_1980.reset();
							Class39_Sub5_Sub16.aCRC32_1980.update(Class42.aClass39_Sub6_788.buffer, 0, i_14_);
							int i_19_ = (int) Class39_Sub5_Sub16.aCRC32_1980.getValue();
							if (CacheArchive.aClass39_Sub5_Sub3_1285.anInt1725 != i_19_) {
								try {
									Deque.aClass16_923.killThread(-2158);
								} catch (Exception exception) {
									/* empty */
								}
								Applet_Sub1.aByte1 = (byte) (int) (Math.random() * 255.0 + 1.0);
								Deque.aClass16_923 = null;
								Class20.anInt393++;
								return false;
							}
							Class65.anInt1138 = 0;
							Class20.anInt393 = 0;
							CacheArchive.aClass39_Sub5_Sub3_1285.aClass9_Sub1_1719.method175(Class42.aClass39_Sub6_788.buffer, Class41.aBoolean777, (byte) -106, (CacheArchive.aClass39_Sub5_Sub3_1285.hash & 0xff0000L) == 16711680L, (int) ((CacheArchive.aClass39_Sub5_Sub3_1285.hash) & 0xffffL));
						}
						CacheArchive.aClass39_Sub5_Sub3_1285.unlink();
						if (Class41.aBoolean777)
							Class1.anInt31--;
						else
							Canvas_Sub1.anInt21--;
						CacheArchive.aClass39_Sub5_Sub3_1285 = null;
						Class42.aClass39_Sub6_788 = null;
						Class39_Sub4.anInt1331 = 0;
					} else {
						if (Class39_Sub4.anInt1331 != 512)
							break;
						Class39_Sub4.anInt1331 = 0;
					}
				}
			}
			return true;
		} catch (IOException ioexception) {
			try {
				Deque.aClass16_923.killThread(-2158);
			} catch (Exception exception) {
				/* empty */
			}
			Deque.aClass16_923 = null;
			Class65.anInt1138++;
			return false;
		}
	}

	public static void method344(int i) {
		aClass39_Sub5_Sub10_Sub4_629 = null;
		aClass3_622 = null;
		aClass3_617 = null;
		aClass3_616 = null;
		aClass3_623 = null;
		aClass3_627 = null;
		aClass3_625 = null;
		anIntArray621 = null;
		aClass3_624 = null;
		aClass3_620 = null;
		aClass3_619 = null;
	}

	public void focusGained(FocusEvent focusevent) {
		/* empty */
	}

	public static int method345(byte i) {
		return 5;
	}

	public static void method346(byte i, int i_20_, GameCharacter class39_sub5_sub4_sub4) {
		Class4.method104(i_20_, class39_sub5_sub4_sub4.anInt2275, i + 99, class39_sub5_sub4_sub4.anInt2301);
		if (i != -11)
			method343(122);
	}

	public synchronized void keyReleased(KeyEvent keyevent) {
		if (Class39_Sub5_Sub4_Sub4_Sub1.aClass35_2499 != null) {
			Class39_Sub5_Sub7.anInt1779 = 0;
			int i = keyevent.getKeyCode();
			if (i >= 0 && Player.anIntArray2532.length > i)
				i = Player.anIntArray2532[i] & ~0x80;
			else
				i = -1;
			if (Class18.anInt341 >= 0 && i >= 0) {
				Class39_Sub5_Sub11.anIntArray1847[Class18.anInt341] = i ^ 0xffffffff;
				Class18.anInt341 = Class18.anInt341 + 1 & 0x7f;
				if (Class18.anInt341 == Class46.anInt879)
					Class18.anInt341 = -1;
			}
		}
		keyevent.consume();
	}

	public synchronized void focusLost(FocusEvent focusevent) {
		if (Class39_Sub5_Sub4_Sub4_Sub1.aClass35_2499 != null)
			Class18.anInt341 = -1;
	}

	public void keyTyped(KeyEvent keyevent) {
		keyevent.consume();
	}

	public static void method347(boolean bool, CacheIO class6, CacheArchive class9_sub1, int i) {
		Class39_Sub9 class39_sub9 = new Class39_Sub9();
		class39_sub9.aClass9_Sub1_1406 = class9_sub1;
		class39_sub9.aClass6_1409 = class6;
		class39_sub9.hash = (long) i;
		class39_sub9.anInt1410 = 1;
		synchronized (RSSocket.aClass49_304) {
			RSSocket.aClass49_304.method956(class39_sub9);
		}
		Class65.method1095(117);
	}

	static {
		aClass3_616 = aClass3_617;
		aClass3_619 = Class39_Sub5_Sub9.createJString(109, "Der Anmelde)2Server ist offline)3");
		anIntArray621 = new int[500];
		aClass3_625 = Class39_Sub5_Sub9.createJString(123, "Friends");
		aClass3_624 = aClass3_625;
		serverSessionKey = 0L;
		aClass3_620 = Class39_Sub5_Sub9.createJString(117, "Checking for updates )2 ");
		aClass3_623 = aClass3_620;
		aClass3_627 = Class39_Sub5_Sub9.createJString(109, "Loading game screen )2 ");
		aClass3_622 = aClass3_627;
	}
}
